package jm.demo.jaxb.permission;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlType;

@XmlType(propOrder= {"name", "acl", "scope"})
public class SecurityObject {
	
	private String name;
	private List<String> acl;
	private String scope;
	
	
	

	public String getName() {
		return name;
	}




	public void setName(String name) {
		this.name = name;
	}


	public List<String> getAcl() {
		return acl;
	}




	public void setAcl(List<String> acl) {
		this.acl = acl;
	}




	public String getScope() {
		return scope;
	}




	public void setScope(String scope) {
		this.scope = scope;
	}




	public static SecurityObject randomOne() {
		SecurityObject result = new SecurityObject();
        result.setName("roleName-"  + SecurityContextManager.random.nextInt());
        ArrayList<String> acl = new ArrayList<String>();
        acl.add("acl-"  + SecurityContextManager.random.nextInt());
        result.setAcl(acl);
        result.setScope("scope-" + SecurityContextManager.random.nextInt());
       
		return result;
	}




	@Override
	public String toString() {
		return "SecurityObject [name=" + name + ", acl=" + acl + ", scope="
				+ scope + "]";
	}




	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((acl == null) ? 0 : acl.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((scope == null) ? 0 : scope.hashCode());
		return result;
	}




	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SecurityObject other = (SecurityObject) obj;
		if (acl == null) {
			if (other.acl != null)
				return false;
		} else if (!acl.equals(other.acl))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (scope == null) {
			if (other.scope != null)
				return false;
		} else if (!scope.equals(other.scope))
			return false;
		return true;
	}
	
	
	
	
	

}
